import { RouterProvider } from 'react-router-dom';
import { router } from '@/router';
import { useAppStore } from '@/stores/useAppStore';
import { useEffect } from 'react';
import { logEnvInfo, getEnvConfig } from '@/utils/env';
import { EnvInfo } from '@/components/EnvInfo';

function App() {
  const { theme } = useAppStore();

  // 应用主题到document
  useEffect(() => {
    document.documentElement.classList.toggle('dark', theme === 'dark');
  }, [theme]);

  // 打印环境信息（仅在开发环境）
  useEffect(() => {
    logEnvInfo();
  }, []);

  // 设置页面标题
  useEffect(() => {
    const config = getEnvConfig();
    document.title = config.appTitle;
  }, []);

  return (
    <div className="min-h-screen">
      <RouterProvider router={router} />
      <EnvInfo />
    </div>
  );
}

export default App;